<?php
declare (strict_types = 1);

namespace app\admin\middleware;

use app\admin\service\AdminAdmin as S;
use think\facade\Session;

class AdminCheck
{
    /**
     * 处理请求
     */
    public function handle($request, \Closure $next)
    {
        if(S::isLogin() == false){
            return redirect($request->root().'/login/index');
        }
        $admin = Session::get('admin');
        $request->_admin_id = $admin['id'];
        $request->_admin_username = $admin['username'];
        $request->_admin_nickname = $admin['nickname'];
        (new \app\admin\model\AdminAdminLog)->record();
        return $next($request);
    }
}
